Is Layout

How do I know for sure when Layout is running this code?

Am writing a single script intended for Attr-DXL, or also as Layout, or also as a Trigger, or also On-Demand. The script itself must detect its own context and act accordingly. Here's an example:

if (!null current Trigger)
{}            // Running as trigger
elseif(null obj)
{             // Not Attr-DXL nor Layout, must be On-Demand
   if (null current Object)
   {}             // Not reasonable
   else print "On-Demand: " identifier(current Object) "\n"
}
elseif(!null attrDXLName)
   obj.attrDXLName = "Attr-DXL: " identifier(obj) ""             // Attr-DXL
else
   display("Layout: " identifier(obj) "")             // What else?  Must be a Layout


The problem is that when I have some other Attr-DXL displayed in a view, the Layout portion of this script will sometimes find that "attrDXLName" is not null and will perform the Attr-DXL portion of the script, in this case changing the results to <Attr-DXL: " identifier obj) "">. Getting the same error when using <aDXLName__()> instead of <attrDXLName>. This seems to occur when scrolling the module and not just when the screen is displayed (such as when moving some other windows over the view).

It seems to pick only on one column of Attr-DXL at a time, the one to the left of the layout (or if layout is on the left, the rightmost Attr-DXL). It does this in addition to the correct processing for the layout column.

Very strange. Anyway, anybody got any idea how I can code it so the software knows for sure that its running in Layout?

 

 

  • Louie

 

 


llandale - Wed Jun 08 14:00:06 EDT 2011

Re: Is Layout
Mathias Mamsch - Fri Jun 10 06:41:57 EDT 2011

Hi Louie, when scrolling, DOORS will evaluate the layout DXL a couple of times, the first one being to evaluate the height of the column, by preprocessing the output. I saw an addition at a layout column once, that checked a special function or flag to determine if the layout is running in this mode:

if (getCalculatingLayoutHeight_()) {
            return
        }

 


Maybe this is where the attrDXLName is !null ...

Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: Is Layout
ePiallat - Fri Jun 10 09:58:22 EDT 2011

Mathias Mamsch - Fri Jun 10 06:41:57 EDT 2011

Hi Louie, when scrolling, DOORS will evaluate the layout DXL a couple of times, the first one being to evaluate the height of the column, by preprocessing the output. I saw an addition at a layout column once, that checked a special function or flag to determine if the layout is running in this mode:

if (getCalculatingLayoutHeight_()) {
            return
        }

 


Maybe this is where the attrDXLName is !null ...

Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Hi,

I would rather try the documented getCanvas perm: it should be null outside a layout DXL call.

If I recall properly, a layout DXL was run several times for each refreshed cell, until DOORS knows the appropriate height for the whole line, then everything was re-computed again. This caused very poor performances as soon as more than three DXL columns were displayed.
The problem was fixed around Doors 7 I think.
Anyway a simple script proves that getCalculatingLayoutHeight_ is true one out of three execution of the layout DXL, so it is not reliable to distinguish DXL Attributes from Layout DXL.

Kind Regards,
- Éric

Re: Is Layout
llandale - Fri Jun 10 15:28:24 EDT 2011

ePiallat - Fri Jun 10 09:58:22 EDT 2011
Hi,

I would rather try the documented getCanvas perm: it should be null outside a layout DXL call.

If I recall properly, a layout DXL was run several times for each refreshed cell, until DOORS knows the appropriate height for the whole line, then everything was re-computed again. This caused very poor performances as soon as more than three DXL columns were displayed.
The problem was fixed around Doors 7 I think.
Anyway a simple script proves that getCalculatingLayoutHeight_ is true one out of three execution of the layout DXL, so it is not reliable to distinguish DXL Attributes from Layout DXL.

Kind Regards,
- Éric

Well that worked, getCanvas() consistently predicted a Layout.

Problem is when you use that command before some real getCanvas() in your layout; it seems to mess it up. I have code that makes a layout canvas, but when I insert the 1st line it messes up the Canvas.

if (getCanvas())
{           // Running as layout, do layout stuff
   DBE dbeCan = getCanvas()
   ...
}


For me, the canvas takes on the same depth as the object instead of as deep as the displayed text therein.

I also see, oddly, when I get the text of the column with the layout, that the "getCanvas()" command does NOT predict its a layout, so the function I wrote could not determine the Context. I suppose it could presume Layout if its not Trigger/OnDemand/Layout/AttrDXL, but sheesh.

Too ignorant of Canvases to deal with it.

 

 

  • Louie


Here's the code so far, but not quite working.

 

 

 

// Context return parameters for fContext_GetDxlContext()
const int    c_Context_Trigger  = 0,
                c_Context_OnDemand      = 1,
                c_Context_Layout        = 2,
                c_Context_AttrDXL       = 3,
                c_Context_LouieMadeMistake      = 4
 
//*************************************************
int     fContext_GetDxlContext()
{     // Get the Context of the currently executing DXL, either
        // = c_Context_Trigger          when running as some Trigger
        // = c_Context_OnDemand         when running as some On-Demand script (e.g. menu or DXL window)
        // = c_Context_Layout           when running as a Layout column
        // = c_Context_AttrDXL          when running as Attr DXL
        // = c_Context_LouieMadeMistake otherwise
 
        // Developer's notes: variable 'obj' is pre-defined and is set to non-null for Layout and AttrDXL.
        // Variable attrDXLName gets set for AttrDXL, but for unclear reason's of display
        //      will sometimes take a real value in a layout in a view with other AttrDXL,
        //      so checking that is unreliable.
        // Function DBE getCanvas() only returns a Canvas DBE while inside a layout,
        //      so that function is used (credit Eric Piallat here: 
        //      https://www.ibm.com/developerworks/forums/thread.jspa?threadID=373445&tstart=0)
 
        if (!null current Trigger)                      return(c_Context_Trigger)
        elseif(null obj)                                        return(c_Context_OnDemand)
        elseif(!null (DBE getCanvas()))         return(c_Context_Layout)
        elseif(!null attrDXLName)                       return(c_Context_AttrDXL)
        else
        {  // print ">>fContext_GetDxlContext, Unknown context for this DXL\n"
                                                                return(c_Context_LouieMadeMistake)
        }
}     // end fContext_GetDxlContext()
 
//*************************************************
bool    fContext_IsTrigger()
{     // Is the current DXL context a Trigger?
        return(fContext_GetDxlContext() == c_Context_Trigger)
}     // end fContext_IsTrigger()
 
//*************************************************
bool    fContext_IsOnDemand()
{     // Is the current DXL context On-Demand?
        return(fContext_GetDxlContext() == c_Context_OnDemand)
}    // end fContext_IsOnDemand()
 
//*************************************************
bool    fContext_IsLayout()
{    // Is the current DXL context On-Demand?
        return(fContext_GetDxlContext() == c_Context_Layout)
}    // end fContext_IsLayout()
 
//*************************************************
bool    fContext_IsAttrDXL()
{    // Is the current DXL context On-Demand?
        return(fContext_GetDxlContext() == c_Context_AttrDXL)
}    // end fContext_IsAttrDXL()
 
if (fContext_IsTrigger())
{}            // Running as trigger
elseif(fContext_IsOnDemand())
{             // Not Attr-DXL nor Layout, must be On-Demand
   if (null current Object)
   {}             // Not reasonable
   else print "On-Demand: " identifier(current Object) "\n"
}
elseif(fContext_IsLayout())
   display("Layout: " identifier(obj) "")             // Layout
elseif(fContext_IsAttrDXL())
   obj.attrDXLName = "Attr-DXL: " identifier(obj) ""  // Attr-DXL
else{}

 

Re: Is Layout
Mathias Mamsch - Fri Jun 10 15:54:36 EDT 2011

llandale - Fri Jun 10 15:28:24 EDT 2011

Well that worked, getCanvas() consistently predicted a Layout.

Problem is when you use that command before some real getCanvas() in your layout; it seems to mess it up. I have code that makes a layout canvas, but when I insert the 1st line it messes up the Canvas.

if (getCanvas())
{           // Running as layout, do layout stuff
   DBE dbeCan = getCanvas()
   ...
}


For me, the canvas takes on the same depth as the object instead of as deep as the displayed text therein.

I also see, oddly, when I get the text of the column with the layout, that the "getCanvas()" command does NOT predict its a layout, so the function I wrote could not determine the Context. I suppose it could presume Layout if its not Trigger/OnDemand/Layout/AttrDXL, but sheesh.

Too ignorant of Canvases to deal with it.

 

 

  • Louie


Here's the code so far, but not quite working.

 

 

 

// Context return parameters for fContext_GetDxlContext()
const int    c_Context_Trigger  = 0,
                c_Context_OnDemand      = 1,
                c_Context_Layout        = 2,
                c_Context_AttrDXL       = 3,
                c_Context_LouieMadeMistake      = 4
 
//*************************************************
int     fContext_GetDxlContext()
{     // Get the Context of the currently executing DXL, either
        // = c_Context_Trigger          when running as some Trigger
        // = c_Context_OnDemand         when running as some On-Demand script (e.g. menu or DXL window)
        // = c_Context_Layout           when running as a Layout column
        // = c_Context_AttrDXL          when running as Attr DXL
        // = c_Context_LouieMadeMistake otherwise
 
        // Developer's notes: variable 'obj' is pre-defined and is set to non-null for Layout and AttrDXL.
        // Variable attrDXLName gets set for AttrDXL, but for unclear reason's of display
        //      will sometimes take a real value in a layout in a view with other AttrDXL,
        //      so checking that is unreliable.
        // Function DBE getCanvas() only returns a Canvas DBE while inside a layout,
        //      so that function is used (credit Eric Piallat here: 
        //      https://www.ibm.com/developerworks/forums/thread.jspa?threadID=373445&tstart=0)
 
        if (!null current Trigger)                      return(c_Context_Trigger)
        elseif(null obj)                                        return(c_Context_OnDemand)
        elseif(!null (DBE getCanvas()))         return(c_Context_Layout)
        elseif(!null attrDXLName)                       return(c_Context_AttrDXL)
        else
        {  // print ">>fContext_GetDxlContext, Unknown context for this DXL\n"
                                                                return(c_Context_LouieMadeMistake)
        }
}     // end fContext_GetDxlContext()
 
//*************************************************
bool    fContext_IsTrigger()
{     // Is the current DXL context a Trigger?
        return(fContext_GetDxlContext() == c_Context_Trigger)
}     // end fContext_IsTrigger()
 
//*************************************************
bool    fContext_IsOnDemand()
{     // Is the current DXL context On-Demand?
        return(fContext_GetDxlContext() == c_Context_OnDemand)
}    // end fContext_IsOnDemand()
 
//*************************************************
bool    fContext_IsLayout()
{    // Is the current DXL context On-Demand?
        return(fContext_GetDxlContext() == c_Context_Layout)
}    // end fContext_IsLayout()
 
//*************************************************
bool    fContext_IsAttrDXL()
{    // Is the current DXL context On-Demand?
        return(fContext_GetDxlContext() == c_Context_AttrDXL)
}    // end fContext_IsAttrDXL()
 
if (fContext_IsTrigger())
{}            // Running as trigger
elseif(fContext_IsOnDemand())
{             // Not Attr-DXL nor Layout, must be On-Demand
   if (null current Object)
   {}             // Not reasonable
   else print "On-Demand: " identifier(current Object) "\n"
}
elseif(fContext_IsLayout())
   display("Layout: " identifier(obj) "")             // Layout
elseif(fContext_IsAttrDXL())
   obj.attrDXLName = "Attr-DXL: " identifier(obj) ""  // Attr-DXL
else{}

 

The getCanvas will not work if the layout executes on an invisible object, e.g. when someone filters on a DXL layout column. In this case getCanvas() will always return null.

By the way, why would you want to distinguish between a layout, attribute DXL or trigger DXL?

Regards, Mathias

Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Is Layout
Mathias Mamsch - Fri Jun 10 16:13:20 EDT 2011

ePiallat - Fri Jun 10 09:58:22 EDT 2011
Hi,

I would rather try the documented getCanvas perm: it should be null outside a layout DXL call.

If I recall properly, a layout DXL was run several times for each refreshed cell, until DOORS knows the appropriate height for the whole line, then everything was re-computed again. This caused very poor performances as soon as more than three DXL columns were displayed.
The problem was fixed around Doors 7 I think.
Anyway a simple script proves that getCalculatingLayoutHeight_ is true one out of three execution of the layout DXL, so it is not reliable to distinguish DXL Attributes from Layout DXL.

Kind Regards,
- Éric

By the way, when trying this code on my module with 3 visible objects i got:

bool b = getCalculatingLayoutHeight_() 
bool c = null getCanvas() 
print (identifier obj) "/ AttrName=" attrDXLName "/ LayoutHeight= " b "/Null Canvas=" c "\n"

 

 

TC_CUTE-2/ AttrName=DXL Testcase ID/ LayoutHeight= true/Null Canvas=false
TC_CUTE-2/ AttrName=DXL Testcase ID/ LayoutHeight= true/Null Canvas=false
TC_CUTE-2/ AttrName=DXL Testcase ID/ LayoutHeight= true/Null Canvas=false
TC_CUTE-20/ AttrName=DXL Testcase ID/ LayoutHeight= true/Null Canvas=false
TC_CUTE-62/ AttrName=DXL Testcase ID/ LayoutHeight= true/Null Canvas=false
TC_CUTE-2/ AttrName=DXL Testcase ID/ LayoutHeight= false/Null Canvas=false
TC_CUTE-20/ AttrName=DXL Testcase ID/ LayoutHeight= false/Null Canvas=false
TC_CUTE-62/ AttrName=DXL Testcase ID/ LayoutHeight= false/Null Canvas=false



So it seems to me that the getCanvas() will never return false, as long as the object is displayed (which makes sense, since the height of the canvas wants to be calculated), even during the Layout Height calculation path. The next thing I noticed was, that attrDXLName always had a value, since I had an attribute DXL displayed in the same view. Therefore I would say, that DOORS fails to reset attrDXLName to null and the attribute DXL and the layout DXL are all calculated in the same context.

So none of the three options will give you the result, if you are executing layout DXL.

@eric: What DOORS version are you using? For DOORS 8.2 the layout seems to be executed only once using getCalculatingLayoutHeight = false, at least in my example with one layout and one attribute dxl in the view.

Regards, Mathias



 

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: Is Layout
llandale - Fri Jun 10 16:22:16 EDT 2011

Mathias Mamsch - Fri Jun 10 15:54:36 EDT 2011
The getCanvas will not work if the layout executes on an invisible object, e.g. when someone filters on a DXL layout column. In this case getCanvas() will always return null.

By the way, why would you want to distinguish between a layout, attribute DXL or trigger DXL?

Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Partly because I have a programatic need to put similar functionality in different contexts and prefer not having almost identical copies of it; in this case a complicated version of "You may not edit this object". Partly because my library goes lots of places. Mostly because I have deep psycological hunger that I think I can satisfy by doing this kind of stuff.

  • Louie

Re: Is Layout
llandale - Fri Jun 10 17:16:07 EDT 2011

Mathias Mamsch - Fri Jun 10 16:13:20 EDT 2011

By the way, when trying this code on my module with 3 visible objects i got:

bool b = getCalculatingLayoutHeight_() 
bool c = null getCanvas() 
print (identifier obj) "/ AttrName=" attrDXLName "/ LayoutHeight= " b "/Null Canvas=" c "\n"

 

 

TC_CUTE-2/ AttrName=DXL Testcase ID/ LayoutHeight= true/Null Canvas=false
TC_CUTE-2/ AttrName=DXL Testcase ID/ LayoutHeight= true/Null Canvas=false
TC_CUTE-2/ AttrName=DXL Testcase ID/ LayoutHeight= true/Null Canvas=false
TC_CUTE-20/ AttrName=DXL Testcase ID/ LayoutHeight= true/Null Canvas=false
TC_CUTE-62/ AttrName=DXL Testcase ID/ LayoutHeight= true/Null Canvas=false
TC_CUTE-2/ AttrName=DXL Testcase ID/ LayoutHeight= false/Null Canvas=false
TC_CUTE-20/ AttrName=DXL Testcase ID/ LayoutHeight= false/Null Canvas=false
TC_CUTE-62/ AttrName=DXL Testcase ID/ LayoutHeight= false/Null Canvas=false



So it seems to me that the getCanvas() will never return false, as long as the object is displayed (which makes sense, since the height of the canvas wants to be calculated), even during the Layout Height calculation path. The next thing I noticed was, that attrDXLName always had a value, since I had an attribute DXL displayed in the same view. Therefore I would say, that DOORS fails to reset attrDXLName to null and the attribute DXL and the layout DXL are all calculated in the same context.

So none of the three options will give you the result, if you are executing layout DXL.

@eric: What DOORS version are you using? For DOORS 8.2 the layout seems to be executed only once using getCalculatingLayoutHeight = false, at least in my example with one layout and one attribute dxl in the view.

Regards, Mathias



 

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Didn't keep the code from a couple days ago, but I had a layout printing attrDXLName() and while it usually was correctly null, I noticed that when you scrolled the module it would run the Layout with the name of some attrDXL actually displayed; but when you subsequently moved a window over the module, the layout DXL would fire repeatedly of course but attrDXLName would be back to null. Not sure what to think about that.

Anyway, I came across "Column getColumn()" which appears, as advertised, to return the Column handle of the currently executing Layout, and seems to be null in other situations. Thus, I end up with the following:

// Context return parameters for fContext_GetDxlContext()
const int    c_Context_Trigger  = 0,
                c_Context_OnDemand      = 1,
                c_Context_Layout        = 2,
                c_Context_AttrDXL       = 3,
                c_Context_LouieMadeMistake      = 4
bool    g_Context_ErrorPrinted = false  // Print bad context once per DXL
 
//*************************************************
int     fContext_GetDxlContext()
{     // Get the Context of the currently executing DXL, either
        // = c_Context_Trigger          when running as some Trigger
        // = c_Context_OnDemand         when running as some On-Demand script (e.g. menu or DXL window)
        // = c_Context_Layout           when running as a Layout column
        // = c_Context_AttrDXL          when running as Attr DXL
        // = c_Context_LouieMadeMistake otherwise
 
        // Developer's notes: variable 'obj' is pre-defined and is set to non-null for Layout and AttrDXL.
        // Variable attrDXLName gets set for AttrDXL, but for unclear reason's of display
        //      will sometimes take a real value in a layout in a view with other AttrDXL,
        //      so checking that is unreliable.
        // Function currentColumn() appears to ONLY return a 'Column' handle when
        //      the DXL is indeed running in a layout.
 
        if (!null current Trigger)              return(c_Context_Trigger)
        elseif(null obj)                                return(c_Context_OnDemand)
        elseif(!null currentColumn())           return(c_Context_Layout)
        elseif(!null attrDXLName)               return(c_Context_AttrDXL)
        else
        {  if (! g_Context_ErrorPrinted)
           {  g_Context_ErrorPrinted = true
              print ">>fContext_GetDxlContext, Unknown context for this DXL\n"
           }
                                                        return(c_Context_LouieMadeMistake)
        }
}     // end fContext_GetDxlContext()
 
//*************************************************
bool    fContext_IsTrigger()
{     // Is the current DXL context a Trigger?
        return(fContext_GetDxlContext() == c_Context_Trigger)
}     // end fContext_IsTrigger()
 
//*************************************************
bool    fContext_IsOnDemand()
{     // Is the current DXL context On-Demand?
        return(fContext_GetDxlContext() == c_Context_OnDemand)
}    // end fContext_IsOnDemand()
 
//*************************************************
bool    fContext_IsLayout()
{    // Is the current DXL context On-Demand?
        return(fContext_GetDxlContext() == c_Context_Layout)
}    // end fContext_IsLayout()
 
//*************************************************
bool    fContext_IsAttrDXL()
{    // Is the current DXL context On-Demand?
        return(fContext_GetDxlContext() == c_Context_AttrDXL)
}    // end fContext_IsAttrDXL()


Add this code and deploy in Layout AttrDXL and on-demand and its seems to work:

 

if (fContext_IsTrigger())
{}            // Running as trigger
elseif(fContext_IsOnDemand())
{             // Not Attr-DXL nor Layout, must be On-Demand
   if (null current Object)
   {}             // Not reasonable
   else print "On-Demand: " identifier(current Object) "\n"
}
elseif(fContext_IsLayout())
   display("Layout: " identifier(obj) "")             // What else?  Must be a Layout
elseif(fContext_IsAttrDXL())
   obj.attrDXLName = "Attr-DXL: " identifier(obj) ""             // Attr-DXL
else{}


Run follwing also on-demand:

 

 

print "Curr Col = " (null currentColumn()) "\n"
 
Module g_mCurr = current
int iCol = getSelectedCol(g_mCurr)
Column col = column(g_mCurr, iCol)
string Text = text(col, (current Object))
print "from column " iCol "  [" Text "]\n"


For On-Demand, select the column with the corresponding layout code.
For layout, delete and hide and objects and I never get the printed unknown context message.

 

 

 

  • Louie

 

 

Re: Is Layout
ePiallat - Tue Jun 14 08:04:38 EDT 2011

Mathias Mamsch - Fri Jun 10 16:13:20 EDT 2011

By the way, when trying this code on my module with 3 visible objects i got:

bool b = getCalculatingLayoutHeight_() 
bool c = null getCanvas() 
print (identifier obj) "/ AttrName=" attrDXLName "/ LayoutHeight= " b "/Null Canvas=" c "\n"

 

 

TC_CUTE-2/ AttrName=DXL Testcase ID/ LayoutHeight= true/Null Canvas=false
TC_CUTE-2/ AttrName=DXL Testcase ID/ LayoutHeight= true/Null Canvas=false
TC_CUTE-2/ AttrName=DXL Testcase ID/ LayoutHeight= true/Null Canvas=false
TC_CUTE-20/ AttrName=DXL Testcase ID/ LayoutHeight= true/Null Canvas=false
TC_CUTE-62/ AttrName=DXL Testcase ID/ LayoutHeight= true/Null Canvas=false
TC_CUTE-2/ AttrName=DXL Testcase ID/ LayoutHeight= false/Null Canvas=false
TC_CUTE-20/ AttrName=DXL Testcase ID/ LayoutHeight= false/Null Canvas=false
TC_CUTE-62/ AttrName=DXL Testcase ID/ LayoutHeight= false/Null Canvas=false



So it seems to me that the getCanvas() will never return false, as long as the object is displayed (which makes sense, since the height of the canvas wants to be calculated), even during the Layout Height calculation path. The next thing I noticed was, that attrDXLName always had a value, since I had an attribute DXL displayed in the same view. Therefore I would say, that DOORS fails to reset attrDXLName to null and the attribute DXL and the layout DXL are all calculated in the same context.

So none of the three options will give you the result, if you are executing layout DXL.

@eric: What DOORS version are you using? For DOORS 8.2 the layout seems to be executed only once using getCalculatingLayoutHeight = false, at least in my example with one layout and one attribute dxl in the view.

Regards, Mathias



 

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Nice job Louis!

@Mathias: I am running DOORS 9.0 for this test, and use the following (very) dirty code:

print "\tA" (identifier obj) ""
if (getCalculatingLayoutHeight_) print "B" (identifier obj) ""
if (!null getCanvas()) print "C" (identifier obj) ""

 


Hovering another window above I get similar results as yours:

 

 

A11C11    A5C5  A6C6    A7C7    A8C8    A9C9    A10C10  A11C11  A5C5    A6C6    A7C7
        A8C8    A9C9    A10C10  A11C11  A5C5    A6C6    A7C7    A8C8    A9C9    A10C10  A11C11
        A5C5    A6C6    A7C7    A8C8    A9C9    A10C10  A11C11  A5C5    A6C6    A7C7    A8C8
        A9C9    A10C10  A11C11  A5C5    A6C6    A7C7    A8C8    A9C9    A10C10  A11C11  A5C5
        A6C6    A7C7    A8C8    A9C9    A10C10  A11C11


But selecting an object I get this: (displayed objects are #20 to #26, selected object is #22)

 

 

A20B20C20    A21B21C21  A22B22C22       A22B22C22       A20B20C20       A21B21C21
        A22B22C22       A23B23C23       A24B24C24       A25B25C25       A26B26C26       A20C20
        A21C21  A22C22  A23C23  A24C24  A25C25  A26C26



Regards,

- Éric



 

Re: Is Layout
llandale - Tue Jun 21 12:38:17 EDT 2011

llandale - Fri Jun 10 17:16:07 EDT 2011

Didn't keep the code from a couple days ago, but I had a layout printing attrDXLName() and while it usually was correctly null, I noticed that when you scrolled the module it would run the Layout with the name of some attrDXL actually displayed; but when you subsequently moved a window over the module, the layout DXL would fire repeatedly of course but attrDXLName would be back to null. Not sure what to think about that.

Anyway, I came across "Column getColumn()" which appears, as advertised, to return the Column handle of the currently executing Layout, and seems to be null in other situations. Thus, I end up with the following:

// Context return parameters for fContext_GetDxlContext()
const int    c_Context_Trigger  = 0,
                c_Context_OnDemand      = 1,
                c_Context_Layout        = 2,
                c_Context_AttrDXL       = 3,
                c_Context_LouieMadeMistake      = 4
bool    g_Context_ErrorPrinted = false  // Print bad context once per DXL
 
//*************************************************
int     fContext_GetDxlContext()
{     // Get the Context of the currently executing DXL, either
        // = c_Context_Trigger          when running as some Trigger
        // = c_Context_OnDemand         when running as some On-Demand script (e.g. menu or DXL window)
        // = c_Context_Layout           when running as a Layout column
        // = c_Context_AttrDXL          when running as Attr DXL
        // = c_Context_LouieMadeMistake otherwise
 
        // Developer's notes: variable 'obj' is pre-defined and is set to non-null for Layout and AttrDXL.
        // Variable attrDXLName gets set for AttrDXL, but for unclear reason's of display
        //      will sometimes take a real value in a layout in a view with other AttrDXL,
        //      so checking that is unreliable.
        // Function currentColumn() appears to ONLY return a 'Column' handle when
        //      the DXL is indeed running in a layout.
 
        if (!null current Trigger)              return(c_Context_Trigger)
        elseif(null obj)                                return(c_Context_OnDemand)
        elseif(!null currentColumn())           return(c_Context_Layout)
        elseif(!null attrDXLName)               return(c_Context_AttrDXL)
        else
        {  if (! g_Context_ErrorPrinted)
           {  g_Context_ErrorPrinted = true
              print ">>fContext_GetDxlContext, Unknown context for this DXL\n"
           }
                                                        return(c_Context_LouieMadeMistake)
        }
}     // end fContext_GetDxlContext()
 
//*************************************************
bool    fContext_IsTrigger()
{     // Is the current DXL context a Trigger?
        return(fContext_GetDxlContext() == c_Context_Trigger)
}     // end fContext_IsTrigger()
 
//*************************************************
bool    fContext_IsOnDemand()
{     // Is the current DXL context On-Demand?
        return(fContext_GetDxlContext() == c_Context_OnDemand)
}    // end fContext_IsOnDemand()
 
//*************************************************
bool    fContext_IsLayout()
{    // Is the current DXL context On-Demand?
        return(fContext_GetDxlContext() == c_Context_Layout)
}    // end fContext_IsLayout()
 
//*************************************************
bool    fContext_IsAttrDXL()
{    // Is the current DXL context On-Demand?
        return(fContext_GetDxlContext() == c_Context_AttrDXL)
}    // end fContext_IsAttrDXL()


Add this code and deploy in Layout AttrDXL and on-demand and its seems to work:

 

if (fContext_IsTrigger())
{}            // Running as trigger
elseif(fContext_IsOnDemand())
{             // Not Attr-DXL nor Layout, must be On-Demand
   if (null current Object)
   {}             // Not reasonable
   else print "On-Demand: " identifier(current Object) "\n"
}
elseif(fContext_IsLayout())
   display("Layout: " identifier(obj) "")             // What else?  Must be a Layout
elseif(fContext_IsAttrDXL())
   obj.attrDXLName = "Attr-DXL: " identifier(obj) ""             // Attr-DXL
else{}


Run follwing also on-demand:

 

 

print "Curr Col = " (null currentColumn()) "\n"
 
Module g_mCurr = current
int iCol = getSelectedCol(g_mCurr)
Column col = column(g_mCurr, iCol)
string Text = text(col, (current Object))
print "from column " iCol "  [" Text "]\n"


For On-Demand, select the column with the corresponding layout code.
For layout, delete and hide and objects and I never get the printed unknown context message.

 

 

 

  • Louie

 

 

Aaaaarrrrrrgh.

Making my first serious foray into "ModuleProperties" with a view towards deciding not to bother opening a module for batch work if we know if hasn't changed. Queried a Module level Attr-DXL and I see that, when using ModuleProperties, the "obj" parameter in the attr-DXL is null. Thus, fContext_GetDxlContext() is incorrect as written below.

I think we can fix this by inserting the 2nd line below into the case statement, but wonder if its enough:

if (!null current Trigger)      return(c_Context_Trigger)
        elseif(null obj and !null attrDXLName)  return(c_Context_AttrDXL)
        elseif(null obj)                        return(c_Context_OnDemand)
        elseif(!null currentColumn())           return(c_Context_Layout)
        elseif(!null attrDXLName)               return(c_Context_AttrDXL)
        else

 


And it appears then that attr-DXL could perhaps routinely have this at the top:
if (null obj or level(obj) <=0) //
then this is a module-level ATTR dxl and act accordingly
else this is an object-level ATTR dxl

 

 

 

  • Louie